package pl.com.qapps.util;

import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

/**
 * @author Jakub Dykowski
 * 
 */
public class LinkListTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String[] strings = { "pierwszy", "drugi", "trzeci", "czwarty", "piąty",
				"szósty", "siódmy", "ósmy", "dziweiąty", "dziesiąty" };
		final List<String> lstrings = new ArrayList<>();
		Collections.addAll(lstrings, strings);
		
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		lstrings.addAll(lstrings);
		
		System.out.println(lstrings.size());

		Queue<String> q = new LinkList<>();
		System.out.println(new LinkedList<String>(q));

		final ArrayList<String> al = new ArrayList<>();
		final LinkedList<String> ll = new LinkedList<>();
		final LinkList<String> linkList = new LinkList<>();

		System.out.println(new Test() {

			@Override
			public void run() {
				al.addAll(lstrings);
			}

		}.test());
		System.out.println(new Test() {

			@Override
			public void run() {
				ll.addAll(lstrings);
			}

		}.test());

		System.out.println(new Test() {

			@Override
			public void run() {
				linkList.addAll(lstrings);
			}

		}.test());
		
//		linkList.addAll(lstrings);
		System.out.println(new Test() {

			@Override
			public void run() {
				linkList.size();
			}

		}.test());
		System.out.println(linkList.size());
	}

	static class Tester {

		private OutputStream out;

		public Tester() {
			this(System.out);
		}

		public Tester(OutputStream out) {
			if (out == null)
				throw new NullPointerException();
			this.out = out;
		}

		void test(Test test) {

		}
	}

	abstract static class Test implements Runnable {

		long test() {
			long start = System.currentTimeMillis();
			run();
			long stop = System.currentTimeMillis();
			return stop - start;
		}

	}
}
